package com.frxuexi.video.adapter

import android.view.View
import androidx.databinding.DataBindingUtil
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.viewholder.BaseViewHolder
import com.frxuexi.lib_base.entity.VideoBeanItem
import com.frxuexi.lib_base.utils.GlideUtils
import com.frxuexi.video.R
import com.frxuexi.video.databinding.ItemVideoBinding

class VideoAdapter:BaseQuickAdapter<VideoBeanItem,BaseViewHolder>(R.layout.item_video) {

    override fun onItemViewHolderCreated(viewHolder: BaseViewHolder, viewType: Int) {
        super.onItemViewHolderCreated(viewHolder, viewType)
        DataBindingUtil.bind<ItemVideoBinding>(viewHolder.itemView)
    }

    override fun convert(helper: BaseViewHolder, item: VideoBeanItem) {
        val binding = DataBindingUtil.getBinding<ItemVideoBinding>(helper.itemView)!!
        binding.gsy.apply {
            setUp(item.videopath,true,item.title)
            backButton.visibility= View.GONE
            titleTextView.visibility=View.GONE
            if(helper.position==0){
                startPlayLogic()
            }
            setBottomProgressBarDrawable(null)
        }

        binding.name.setText(item.name)
        binding.videoTitle.setText(item.title)

        GlideUtils.loadCircleImage(item.avatar_url,binding.ivUserIcon)
        GlideUtils.loadCircleImage(item.avatar_url,binding.ivUserIcon2)
    }
}